package com.zhuangwei.spring.config;

import com.zhuangwei.spring.hook.interceptor.MyRefererInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 主要作用就是开启WebMVC
 *
 * @author 文希
 * @create 2019-05-23 14:44
 **/
@Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {

    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration addInterceptor = registry.addInterceptor(new MyRefererInterceptor());
        addInterceptor.excludePathPatterns("/hello");
        addInterceptor.addPathPatterns("/**");
    }
}
